package com.gljx.web.service.impl;

import com.gljx.web.Entity.ExamOrder;
import com.gljx.web.dao.CommonDao;
import com.gljx.web.dao.ExamOrderMapper;
import com.gljx.web.service.ExamOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ExamOrderServiceImpl extends CommonDao implements ExamOrderService {

	@Autowired
	private ExamOrderMapper examOrderMapper;
	
	
	
	/**
	 *取分页数据    dmz 20160921
	 *@param pindex 页码
	 *@param psql SQL语句，需要带 rownum rn 例如：select rownum rn,t.* from zzda t
	 *@param psize 每页记录数
	 * */
	@Override
	public Map<String, Object> selectPage(int pindex, String psql, int psize) {
		  Map<String, Object> paramMap = new HashMap<String, Object>();
	       paramMap.put("Pindex", pindex);
	       paramMap.put("Psql", psql);
	       paramMap.put("Psize", psize);
	       paramMap.put("Pcount", oracle.jdbc.OracleTypes.INTEGER);
	       paramMap.put("v_cur", oracle.jdbc.OracleTypes.CURSOR);
	       this.getSqlSession().select("com.gljx.web.dao.ExamOrderMapper.pagemap", paramMap, null);
	       return  paramMap;
	}

	/**
	 * 取记录总数      dmz 20160921
	 * @param psql   SQL语句
	 * @param Pcount 记录总数
	 * @return
	 */
	@Override
	public Map<String, Object> selectPageCount(String psql) {
		   Map<String, Object> paramMap = new HashMap<String, Object>();
	       paramMap.put("Psql", psql);
	       paramMap.put("Pcount", oracle.jdbc.OracleTypes.INTEGER);
	       this.getSqlSession().select("com.gljx.web.dao.ExamOrderMapper.pagecount", paramMap, null);
	       return paramMap;
	}

	@Override
	public void insertExamOrder(ExamOrder examOrder) {
		// TODO Auto-generated method stub
		examOrderMapper.insertSelective(examOrder);
	}

	@Override
	public void deleteExamOrderByFid(String[] fids) {
		// TODO Auto-generated method stub
		examOrderMapper.deleteExamOrderByFid(fids);
	}

	@Override
	public ExamOrder selectExamOrderByFid(String fid) {
		// TODO Auto-generated method stub
		return examOrderMapper.selectExamOrderByFid(fid);
	}

	@Override
	public void updateExamOrder(ExamOrder examOrder) {
		// TODO Auto-generated method stub
		examOrderMapper.updateByPrimaryKeySelective(examOrder);
	}

	@Override
	public List<ExamOrder> selectExamOrderByDate(String cfexamdate, String fcompanyid, String cartype, String billState, String reslut) {
		Map map = new HashMap();
		    map.put("cfexamdate",cfexamdate);
		    map.put("fcompanyid",fcompanyid);
		    map.put("reslut",reslut);
		    map.put("billState",billState);
		    map.put("cartype",cartype);
		return examOrderMapper.selectExamOrderByDate(map);
	}


}
